/*
    This file is part of the KDE libraries
    SPDX-FileCopyrightText: ?

    SPDX-License-Identifier: ?
*/

#ifndef DELETEORTRASHJOBHANDLERINTERFACE_H
#define DELETEORTRASHJOBHANDLERINTERFACE_H

#include <KService>
#include <QObject>

#include <kio/askuseractioninterface.h> // DeletionType, ConfirmationType
#include <kiogui_export.h>
class QString;

class KJob;

namespace KIO
{
class DeleteOrTrashJobHandlerInterfacePrivate;

/**
 * @class DeleteOrTrashJobHandlerInterface deleteortrashjobhandlerinterface.h <KIO/DeleteOrTrashJobHandlerInterface>
 * @brief The DeleteOrTrashJobHandlerInterface class allows OpenUrlJob to start DeleteOrTrashJob that
 * ask the user for confirmation to delete or move to Trash a list of URLs (like broken symlink).
 *
 * This extension mechanism for jobs is similar to KIO::JobUiDelegateExtension,
 * OpenWithHandlerInterface, UntrustedProgramHandlerInterface and OpenOrExecuteFileInterface.
 *
 * @since ?
 */
class KIOGUI_EXPORT DeleteOrTrashJobHandlerInterface : public QObject
{
    Q_OBJECT
protected:
    /**
     * Constructor
     */
    explicit DeleteOrTrashJobHandlerInterface(QObject *parent = nullptr);

    /**
     * Destructor
     */
    ~DeleteOrTrashJobHandlerInterface() override;

public:
    /**
     * Start DeleteOrTrashJob that ask for confirmation
     * before moving @p urls (files/directories) to the Trash,
     * or directly deleting files (i.e. without moving to Trash).
     * @param job the job calling this. Useful to get all its properties
     * @param urls the list of urls to delete, move to Trash, or an empty list
     * in the case of AskUserActionInterface::EmptyTrash (in the latter case,
     * the list of urls is ignored)
     * @param deletionType one of AskUserActionInterface::DeletionType
     * @param confirm one of AskUserActionInterface::ConfirmationType
     *
     * Implementations of this method must emit either result or canceled.
     */
    virtual void askUserDeleteOrTrash(KJob *job,
                                      const QList<QUrl> &urls,
                                      AskUserActionInterface::DeletionType deletionType,
                                      AskUserActionInterface::ConfirmationType confirm);

Q_SIGNALS:
    /**
     * Emitted by askUserDeleteOrTrash() once the user chooses an application.
     * @param deleted true if deletion is success
     */
    void result(bool deleted);

    /**
     * Emitted by askUserDeleteOrTrash() if the user canceled the confirmation dialog.
     */
    void canceled();

private:
    QScopedPointer<DeleteOrTrashJobHandlerInterfacePrivate> d;
};

}

#endif // DELETEORTRASHJOBHANDLERINTERFACE_H
